import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { RuleInfoVO, RuleInfoForm, RuleInfoQuery } from '@/api/device/ruleInfo/types';

/**
 * 查询规则信息列表
 * @param query
 * @returns {*}
 */

export const listRuleInfo = (query?: RuleInfoQuery): AxiosPromise<RuleInfoVO[]> => {
  return request({
    url: '/system/ruleInfo/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询规则信息详细
 * @param id
 */
export const getRuleInfo = (id: string | number): AxiosPromise<RuleInfoVO> => {
  return request({
    url: '/system/ruleInfo/' + id,
    method: 'get'
  });
};

/**
 * 新增规则信息
 * @param data
 */
export const addRuleInfo = (data: RuleInfoForm) => {
  return request({
    url: '/system/ruleInfo',
    method: 'post',
    data: data
  });
};

/**
 * 修改规则信息
 * @param data
 */
export const updateRuleInfo = (data: RuleInfoForm) => {
  return request({
    url: '/system/ruleInfo',
    method: 'put',
    data: data
  });
};

/**
 * 删除规则信息
 * @param id
 */
export const delRuleInfo = (id: string | number | Array<string | number>) => {
  return request({
    url: '/system/ruleInfo/' + id,
    method: 'delete'
  });
};
